<?php
/**
 * Email:y7wanghui@gmail.com
 * File_Name:artical.php
 */


require_once "database.php";

$sql = "SELECT * FROM  `article` ORDER BY `id` LIMIT 0,10";

$result = $conn->query($sql);

$arr = [];
if ($result->num_rows > 0) {
    // 输出数据
    while($row = $result->fetch_assoc()) {

        $title = $row['title'];
        $datetime = $row['datetime'];
        $artical_id = $row["id"];
        $res  = ['title'=>$title,'datetime'=>$datetime,'artical_id'=>$artical_id];
        array_push($arr,$res);
    }
} else {
    echo "0 结果";
}




echo json_encode($arr);
//var_dump($arr);
